<?php
namespace app\core\repositories\user\read;

use app\core\entities\User;

class UserReadRepository
{
    public function find(string $id): ?User
    {
        return User::findOne(['id' => $id]);
    }

    public function findByEmail($value): ?User
    {
        return User::findOne(['email' => $value, 'status' => User::STATUS_ACTIVE]);
    }

    public function findByAccessToken($token): ?User
    {
        return User::findOne(['auth_key' => $token, 'status' => User::STATUS_ACTIVE]);
    }

    public function findActiveById(string $id): ?User
    {
        return User::findOne(['id' => $id, 'status' => User::STATUS_ACTIVE]);
    }
}
